import instance from "@/utils/request";

export function list(page, size, role) {
  return instance({
    method: "post",
    url: `/role/list/${page}/${size}`,
    data: role
  });
}

export function add(role) {
  return instance({
    method: "post",
    url: `/role/add`,
    data: role
  });
}

export function getOne(id) {
  return instance({
    method: "get",
    url: `/role/${id}`
  });
}

export function del(id) {
  return instance({
    method: "delete",
    url: `/role/${id}`
  });
}

export function grantResToRole(roleId, resourceIds) {
  return instance({
    method: "post",
    url: `/role/grantResToRole`,
    data: {
      roleId,
      resourceIds
    }
  });
}

export function getResIdsByRoleId(roleId) {
  return instance({
    method: "get",
    url: `/role/getResIdsByRoleId/${roleId}`
  });
}
